﻿using System.Collections.Generic;
using System.Configuration;
using System.Linq;

namespace SwissTV.Entities.Social
{
    public class SocialConfigCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new SocialConfigElement();
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((SocialConfigElement)element).Authentication;
        }

        public SocialConfigElement this[int index]
        {
            get { return (SocialConfigElement)BaseGet(index); }
        }
        new public SocialConfigElement this[string name]
        {
            get { return (SocialConfigElement)BaseGet(name); }
        }
    }

    public class UrlCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new UrlElement();
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((UrlElement)element).Name;
        }

        public UrlElement this[int index]
        {
            get { return (UrlElement)BaseGet(index); }
        }
        new public UrlElement this[string name]
        {
            get { return (UrlElement)BaseGet(name); }
        }

        public List<UrlInfo> getUrls()
        {
            return this.Cast<UrlElement>().Select(p => new UrlInfo(p.Name, p.Value)).ToList();
        }
    }

}

